//
//  ActionViewController.m
//  bluetooth
//
//  Created by 周季阳 on 15/6/17.
//  Copyright (c) 2015年 switch. All rights reserved.
//

#import "ActionViewController.h"
#import "UIViewAdditions.h"
#import "MaterialViewController.h"
#import "WaterViewController.h"
#import "AppDelegate.h"
#import "MeiYanViewController.h"
#import "ShopViewController.h"
@interface ActionViewController ()<UIAlertViewDelegate>

@end

@implementation ActionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createrView];
}
#pragma mark - initUI
-(void)createrView{
    UIImageView * imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"制作完成.png"]];
    [imgView setFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:imgView];
    imgView.userInteractionEnabled = YES;
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(10, 40, 78, 26);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"15清洗-清洁导流槽_03(1)"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(clickLeftBtn) forControlEvents:UIControlEventTouchUpInside];
    [imgView addSubview:leftBtn];
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame = CGRectMake(SCREEN_WIDTH-88, 40, 78, 26);
    [rightBtn setBackgroundImage:[UIImage imageNamed:@"制作完成_05"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(clickRightBtn) forControlEvents:UIControlEventTouchUpInside];
    [imgView addSubview:rightBtn];
    
    UIButton *actionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    actionBtn.frame = CGRectMake((SCREEN_WIDTH-93)/2, SCREEN_HEIGHT/2-60, 93, 84);
    [actionBtn setBackgroundImage:[UIImage imageNamed:@"开始_03"] forState:UIControlStateNormal];
    [actionBtn addTarget:self action:@selector(clickActionBtn) forControlEvents:UIControlEventTouchUpInside];
    [imgView addSubview:actionBtn];
    
    UILabel *zTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, actionBtn.bottom+60, SCREEN_WIDTH, 30)];
    zTitle.textColor = [UIColor whiteColor];
    zTitle.backgroundColor = [UIColor clearColor];
    zTitle.textAlignment = NSTextAlignmentCenter;
    zTitle.text = @"连接成功，可以开始制模面膜";
    zTitle.font = [UIFont systemFontOfSize:16];
    [imgView addSubview:zTitle];
    
}
#pragma mark - 开始
-(void)clickActionBtn{
    //MaterialViewController *material = [[MaterialViewController alloc]init];
    //[self.navigationController pushViewController:material animated:YES];
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.isWhere = @"4";

    if (ISWHAT == 0) {
        //WaterViewController *water = [[WaterViewController alloc]init];
        MeiYanViewController *water = [[MeiYanViewController alloc]init];
        [self.navigationController pushViewController:water animated:YES];
    }else{
        //MaterialViewController *mate = [[MaterialViewController alloc]init];
        MeiYanViewController *mate = [[MeiYanViewController alloc]init];
        [self.navigationController pushViewController:mate animated:YES];
    }
    
}
#pragma mark - 返回上一步
-(void)clickLeftBtn{
//    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
//    appDelegate.isWhere = @"2";
//    [self.navigationController popViewControllerAnimated:YES];
    ShopViewController *shop  = [[ShopViewController alloc]init];
    [self.navigationController pushViewController:shop animated:YES];
}
#pragma mark - 退出
-(void)clickRightBtn{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"您确定退出么" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
    [alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        [[NSNotificationCenter defaultCenter]postNotificationName:@"cleanUp" object:nil];
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
